/*
 * ConfirmationDialog.java
 *
 * Created on March 16, 2007, 5:55 PM
 */

package busticketvendingsystem;
import busticketvendingsystem.*;

/**
 *
 * @author  Samik Saha
 */
public class ConfirmationDialog extends javax.swing.JDialog {
    java.awt.Frame parent;
    ConnectDatabase cd=new ConnectDatabase();
    String fare[]=cd.getFare();
    static private busticketvendingsystem.UserData userData;
    /** Creates new form ConfirmationDialog */
    public ConfirmationDialog(java.awt.Frame parentFrame, boolean modal,UserData ud) {
        super(parentFrame, modal);
        parent=parentFrame;
        userData=new UserData();
        if(ud!=null)
            userData=ud;
        initComponents();
        setLocationRelativeTo(parent);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel3 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        rightPanel = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        centerPanel = new javax.swing.JPanel();
        directionLabel = new javax.swing.JLabel();
        startingStopLabel = new javax.swing.JLabel();
        dstnLabel = new javax.swing.JLabel();
        noTicketsLabel = new javax.swing.JLabel();
        scheduleTimeLabel = new javax.swing.JLabel();
        busNumberLabel = new javax.swing.JLabel();
        availableSeatsLabel = new javax.swing.JLabel();
        dateLabel = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Confirm");
        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/busticketvendingsystem/resources/images/confirm_info.gif")));
        jLabel3.setText("PLEASE CONFIRM THE FOLLOWING INFORMATION");
        getContentPane().add(jLabel3, java.awt.BorderLayout.NORTH);

        jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

        jButton2.setText("OK");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jPanel2.add(jButton2);

        jButton1.setText("Cancel");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel2.add(jButton1);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/busticketvendingsystem/resources/images/help_icon_small.gif")));
        jButton3.setText("Help");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jPanel2.add(jButton3);

        getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel12.setText("Ticket type:");

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel13.setText("Concession type:");

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel14.setText("Amount to be paid:");

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel15.setText("Diatance:");

        jLabel16.setText(""+userData.getAmount());

        jLabel17.setText(userData.getConcessionTypeName());

        jLabel18.setText(userData.getTicketTypeName());

        jLabel19.setText(""+userData.getDistance());

        org.jdesktop.layout.GroupLayout rightPanelLayout = new org.jdesktop.layout.GroupLayout(rightPanel);
        rightPanel.setLayout(rightPanelLayout);
        rightPanelLayout.setHorizontalGroup(
            rightPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(rightPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(rightPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel14)
                    .add(jLabel13)
                    .add(jLabel12)
                    .add(jLabel15))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(rightPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel19)
                    .add(jLabel16)
                    .add(jLabel17)
                    .add(jLabel18))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        rightPanelLayout.setVerticalGroup(
            rightPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(rightPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(rightPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel12)
                    .add(jLabel18))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(rightPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel13)
                    .add(jLabel17))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 86, Short.MAX_VALUE)
                .add(rightPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel15)
                    .add(jLabel19))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(rightPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel14)
                    .add(jLabel16))
                .addContainerGap())
        );
        getContentPane().add(rightPanel, java.awt.BorderLayout.EAST);

        directionLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        directionLabel.setText("Direction:");

        startingStopLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        startingStopLabel.setText("Starting stoppage:");

        dstnLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        dstnLabel.setText("Destination stoppage:");

        noTicketsLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        noTicketsLabel.setText("Number of tickets:");

        scheduleTimeLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        scheduleTimeLabel.setText("Schedule time:");

        busNumberLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        busNumberLabel.setText("Bus number:");

        availableSeatsLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        availableSeatsLabel.setText("Available seats:");

        dateLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        dateLabel.setText("Date:");

        jLabel4.setText(userData.getDestination());

        jLabel5.setText(userData.getStartingStop());

        jLabel6.setText(userData.getDirectionName());

        jLabel7.setText(""+userData.getNoTickets());

        jLabel8.setText(userData.getScheduleTime());

        jLabel9.setText(userData.getBusNo());

        jLabel10.setText(""+userData.getAvailableSeats());

        jLabel11.setText(""+userData.getDate());

        org.jdesktop.layout.GroupLayout centerPanelLayout = new org.jdesktop.layout.GroupLayout(centerPanel);
        centerPanel.setLayout(centerPanelLayout);
        centerPanelLayout.setHorizontalGroup(
            centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(centerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(dstnLabel)
                    .add(startingStopLabel)
                    .add(directionLabel)
                    .add(noTicketsLabel)
                    .add(scheduleTimeLabel)
                    .add(busNumberLabel)
                    .add(availableSeatsLabel)
                    .add(dateLabel))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel11)
                    .add(jLabel10)
                    .add(jLabel9)
                    .add(jLabel8)
                    .add(jLabel7)
                    .add(jLabel6)
                    .add(jLabel5)
                    .add(jLabel4))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        centerPanelLayout.setVerticalGroup(
            centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(centerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(directionLabel)
                    .add(jLabel6))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(startingStopLabel)
                    .add(jLabel5))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(dstnLabel)
                    .add(jLabel4))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(noTicketsLabel)
                    .add(jLabel7))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(scheduleTimeLabel)
                    .add(jLabel8))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(busNumberLabel)
                    .add(jLabel9))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(availableSeatsLabel)
                    .add(jLabel10))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(centerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(dateLabel)
                    .add(jLabel11))
                .addContainerGap())
        );
        getContentPane().add(centerPanel, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        new HelpWindow(ConfirmationDialog.this,true,"confirmation.htm").setVisible(true);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        dispose();
        new busticketvendingsystem.PaymentForm(parent,true,userData).setVisible(true);
    }//GEN-LAST:event_jButton2ActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ConfirmationDialog(null, true, ConfirmationDialog.userData).setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel availableSeatsLabel;
    private javax.swing.JLabel busNumberLabel;
    private javax.swing.JPanel centerPanel;
    private javax.swing.JLabel dateLabel;
    private javax.swing.JLabel directionLabel;
    private javax.swing.JLabel dstnLabel;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel noTicketsLabel;
    private javax.swing.JPanel rightPanel;
    private javax.swing.JLabel scheduleTimeLabel;
    private javax.swing.JLabel startingStopLabel;
    // End of variables declaration//GEN-END:variables
    
}
